
package com.catsic.core.specification;

import com.catsic.base.specification.BaseSpec;
import com.catsic.base.specification.QueryWraper;
import com.catsic.core.conditon.OrganCondition;
import com.catsic.core.entity.Organ;
/**
 * ClassName: OrganSpec
 * Description: OrganSpec
 * date: 2013年4月28日 下午2:30:29
 * author: yangyd
 */
public class OrganSpec extends BaseSpec<Organ> {

	public OrganSpec(OrganCondition condition){
		super(condition,false);
	}
	
	/**
	 * @see com.catsic.core.specification.BaseSpec#addCondition(com.catsic.core.specification.QueryWraper)
	 */
	@Override
	protected void addCondition(QueryWraper<Organ> queryWraper) {
		OrganCondition condition = (OrganCondition)getCondition();
		addNotEqualCondition(queryWraper, "code");
		addLikeConditionSuffix(queryWraper, queryWraper.getRoot().get("code"), condition.getCode());
		addLikeCondition(queryWraper, "name",  condition.getName());
		/*一对多查询，多表作为条件*/
/*		Join<Organ,List<User>> userJoin =  queryWraper.getRoot().join("users");
		List<String> list = new ArrayList<String>();
		list.add("catsic");
		list.add("catsic0");
		Expression<String> expression = userJoin.get("username");
		addInCondition(queryWraper, queryWraper.getRoot().get("code"), expression);*/
		queryWraper.addOrder(queryWraper.getCb().asc(queryWraper.getRoot().get("code")));
	}
}
